// Created by Roman Novitsky on 19.05.2009


#region Imported Namespaces


using System.Collections.Generic;
using System.Collections.Specialized;
using System.Windows;

using WtfManager.Framework;
using WtfManager.UIManager;


#endregion


namespace WtfManager.FileManager
{
  public class WindowsFileDropDragDataFormatExtension: Service, IDragDataFormatExtension
  {
    #region Properties/Indexers


    public override string Description
    {
      get
      {
        return "Adds support for Windows File Drop drag data format.";
      }
    }

    public override string Name
    {
      get
      {
        return "Windows File Drop Drag Data Format Extension";
      }
    }


    #endregion


    #region Methods


    public void GetDragFormat(DataObject dataObject, List<object> draggedItems)
    {
      var collection = new StringCollection();

      foreach (object draggedItem in draggedItems)
      {
        if (!(draggedItem is FileSystemFile))
        {
          continue;
        }

        var item = (FileSystemItem)draggedItem;
        collection.Add(item.FileSystemPath);
      }

      if (collection.Count != 0)
      {
        dataObject.SetFileDropList(collection);
      }
    }


    protected override void OnStateChnaged()
    {
    }


    protected override void OnUnload()
    {
    }


    protected override FrameworkComponentState OnInitialize()
    {
      return FrameworkComponentState.Initialized;
    }


    protected override FrameworkComponentState OnLoad()
    {
      return FrameworkComponentState.Loaded;
    }


    #endregion
  }
}